import CommentForm from "./CommentForm";
import CommentList from "./CommnetList";
import React from "react";

class Commnet extends React.Component{
    state = {
        commentList:[
            {
                id:1,
                name:'杨亚茹',
                comment:'hello yyr'
            },
            {
                id:2,
                name:'高锐',
                comment:'hello gr'
            }
        ]
    }
    handlerList = (e)=>{
        this.setState({
            commentList:[{id:Math.floor(Math.random()*100),...e},...this.state.commentList]
        })
    }
    render(){
        return (
            <div>
                <CommentForm getForm={this.handlerList}></CommentForm>
                <CommentList list={this.state.commentList}></CommentList>
            </div>
        )
    }
}

export default Commnet